/******************************************************************************
	This file is a part of the Snapshot Bioinformatics Project

	Copyright (C) 2012-2013 Jarom Schow

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#ifndef ESEARCH_H
#define ESEARCH_H

#include "Entrez.h"

#include <QtCore/QDate>

namespace Bio {

class BIO_EXPORT ESearch : public Entrez {
	friend class ESearchResultParser;
public:
	ESearch();
	ESearch( const QString &db, const QString &term, bool useHistory = false );
	virtual ~ESearch();

	virtual bool	exec();

	void	setDatabase( const QString &db );
	QString	getDatabase() const;

	void	setTerm( const QString &term );
	QString	getTerm() const;

	void	setUseHistory( bool onOff );
	bool	getUseHistory() const;

	void	setHistory( int queryKey, const QString &webEnv );
	int		getQueryKey() const;
	QString	getWebEnv() const;

	void	setRetStart( int num );
	int		getRetStart() const;

	void	setRetMax( int num );
	int		getRetMax() const;

	void	setField( const QString &field );
	QString	getField() const;

	void		setDateType( DateType type );
	DateType	getDateType() const;

	void	setRelDate( int num );
	int		getRelDate() const;

	void	setDateRange( const QDate &minDate, const QDate &maxDate );
	QDate	getMinDate() const;
	QDate	getMaxDate() const;

	int		getCount() const;

	int		getNumIDs() const;
	QString	getID( int which ) const;

	QStringListIterator	getIDIterator() const;

private:

	void	setCount( int count );
	void	addID( const QString &id );

	QString		m_db, m_term, m_webEnv, m_field;
	bool		m_useHistory;
	int			m_queryKey, m_retStart, m_retMax, m_relDate, m_count;
	DateType	m_dateType;
	QDate		m_minDate, m_maxDate;
	QStringList	m_ids;
};

}; // Bio

#endif // ESEARCH_H